
from selenium.webdriver.common.by import By


class ArHomePageLocator:
    # AR学术研发平台首页content内容管理模块按钮
    content_loc = (By.XPATH, '//ion-label[text()="内容管理"]')
    # 二级导航--课时管理
    lesson_loc = (By.XPATH, '//ion-label[text()=" 课时管理 "]')
    # 添加课时
    add_lesson_loc = (By.XPATH, '//ion-button[contains(.,"添加")]')
    # 导航栏-题库管理
    question_bank_loc = (By.XPATH, "//ion-label[text()='题库管理']/..")
    # 导航栏-题库管理-题目管理
    subject_loc = (By.XPATH, "//ion-label[text()=' 题目管理 ']/..")
    # 导航栏-题库管理-试卷管理
    test_paper_loc = (By.XPATH, "//ion-label[text()=' 试卷管理 ']/..")


class ArAddLessonLocator:
    """添加课时页"""
    # 课时名称
    lessonName_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'课时名称')]/ion-input/input")

    # 默认课次
    class_times_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'默认课次')]/ion-input/input")
    # 时长
    whenLong_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'时长')]/ion-input/input")
    # 科目 label
    subject_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'科目')]/ion-select")
    # 科目-英语
    mathematics_loc = (By.XPATH, "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'英语')]")
    # 适用学季
    term_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'适用学季')]/ion-select")
    term_chunshang_loc = (By.XPATH, "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'春上')]")
    # 适用水平
    level_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'适用水平')]/ion-select")
    level_p4_loc = (By.XPATH,
                          "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'L Pre4')]")
    # 课时类型
    courseType_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'课时类型')]/ion-select")
    courseType_shipin_loc = (By.XPATH,
                          "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'视频课')]")
    # 类型
    type_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'类型:')]/ion-select")
    type_1v3_loc = (By.XPATH,
                          "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'主课1V3')]")
    type_option_loc = [By.XPATH,
                       "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'{}')]"]
    # 教材类型
    materialType_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'教材类型')]/ion-select")
    materialType_zhu_loc = (By.XPATH,
                          "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'主课')]")
    # 备注信息
    remark_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'备注')]/ion-input/input")
    # 简介
    vocabulary_loc = (By.XPATH, "//div[@class='ql-editor ql-blank']/p")
    # 滚动区域定位
    soll_div = (By.XPATH, "//*[@class='md hydrated']", 60)
    # 确定提交按钮
    confirm_loc = (By.XPATH, "//div[@class='btns'][last()]/ion-button[2]")
    #<div class="toast-message" part="message">课时时长不能为空</div>
    # toast_loc = (By.XPATH, "//div[@class='toast-message']")
    toast_loc = (By.XPATH, "//div[@class='toast-wrapper toast-top']")
    toast_loc = (By.XPATH, "//ion-app[@class='md ion-page hydrated']/ion-toast")

    checkbox_loc = [By.XPATH, '//span[contains(.,"{}")]/../../../datatable-body-cell[1]/div/input']
    release_loc = (By.XPATH, "//ion-button[contains(., '发布')]")
    course_name_loc = (By.XPATH, '//div[@class="search-item"  and contains(.,"称:")]/ion-input/input')
    search_btn_loc = (By.XPATH, "//div[@class='search normalButtonStyle']")


class LessonLocator:
    lesson_name_loc = (By.XPATH, '//div[@class="search-item"  and contains(.,"称:")]/ion-input/input')
    search_btn_loc = (By.XPATH, "//ion-button[@class='courseBtn search normalButtonStyle md button button-solid ion-activatable ion-focusable hydrated']")
    # checkbox_loc = [By.XPATH, '//span[text()="{}"]/../../../datatable-body-cell[1]/div/div/input']
    checkbox_loc = [By.XPATH, '//span[contains(.,"{}")]/../../../datatable-body-cell[1]/div/div/input']
    release_loc = (By.XPATH, "//ion-button[@class='search normalButtonStyle courseBtn md button button-solid ion-activatable ion-focusable hydrated' and contains(., '发布')]")
    create_course_loc = (By.XPATH, "//ion-button[@class='search normalButtonStyle courseBtn md button button-solid ion-activatable ion-focusable hydrated' and contains(., '组课')]")


class ArAddCourseLocator:
    # 课程名称
    course_name_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'课程名称')]/ion-input/input")
    # 课程描述
    course_describe_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'课程描述')]/ion-input/input")
    # 科目
    subject_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'科目')]/ion-select")
    # 科目-英语
    mathematics_loc = (By.XPATH,
                       "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'英语')]")

    # 适用学季
    term_loc = (By.XPATH, "//label[contains(.,'学季')]/following-sibling::ion-select")
    term_chunshang_loc = (By.XPATH,
                          "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'春上')]")
    # 适用水平
    level_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'适用水平')]/ion-select")
    level_p4_loc = (By.XPATH,
                    "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'L Pre4')]")
    # 等级
    garde_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'等级')]/ion-select")
    garde_1_loc = (By.XPATH,
                    "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,' ZKLPre2 ')]")
    # 课时包
    lesson_package_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'课时包')]/ion-select")
    lesson_package_1_loc = (By.XPATH,
                    "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'课时包1')]")
    # 类型
    type_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'类型')]/ion-select")
    type_1v3_loc = (By.XPATH,
                    "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'主课1V3')]")
    type_option_loc = [By.XPATH,
                       "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'{}')]"]

    # 学龄
    school_age_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'学龄')]/ion-select")
    school_small_low_loc = (By.XPATH,
                            "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'小低')]")
    # 年份
    year_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'学年')]/ion-select")
    select_year_loc = (By.XPATH,
                     "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'2022')]")
    # 教学内容
    courses_content_loc = (By.XPATH, "//div[@class='search-item' and contains(.,'教学内容')]/ion-select")
    contents_loc_list = [By.XPATH,
                         "//div[@class='alert-checkbox-group sc-ion-alert-md']/button/div[contains(.,'{content}')][1]/div[1]"]
    confirm_loc = (By.XPATH, "//button[@class='alert-button ion-focusable ion-activatable sc-ion-alert-md']")

    channel_loc = (By.XPATH, "//label[contains(.,'课程渠道')]/following-sibling::ion-select")
    test_channel_loc = (By.XPATH, "//ion-label[text()=' 测试渠道 ']/..")
    # 备注信息
    remark_loc = (By.XPATH, "//textarea[@class='native-textarea sc-ion-textarea-md']")
    # 上课方式
    class_mode_loc = (By.XPATH, "//div[@class ='search-item' and contains(.,'上课方式')]/ion-select")
    # Blingabc
    mode_Blingabc_loc = (By.XPATH,
                         "//ion-item[@class='select-interface-option md sc-ion-select-popover item in-list ion-activatable ion-focusable hydrated item-label' and contains(.,'Blingabc')]")

    # 提交
    submit_confirm_loc = (By.XPATH, "//div[@class='btns']/ion-button[1]")


class CourseManagementLocator:
    # 课程名称
    course_name_loc = (By.XPATH, '//div[@class="search-item"  and contains(.,"称:")]/ion-input/input')
    # 搜索
    search_btn_loc = (By.XPATH, "//div[@class='search normalButtonStyle']")
    # 勾选框
    checkbox_loc = [By.XPATH, "//div[@class='datatable-body-cell-label']/span[contains(.,'{}')]/../../../datatable-body-cell[1]/div/input"]
    # 发布
    release_loc = (By.XPATH,
                   "//ion-button[@class='search normalButtonStyle md button button-solid ion-activatable ion-focusable hydrated' and contains(., '发布')]")

    toast_loc = (By.XPATH, "//ion-app[@class='md ion-page hydrated']/ion-toast")


class QuestionBankManagementLocator:
    # 题目管理--添加
    subject_add_loc = (By.XPATH, "//div[text()=' 添加 ']")
    # 下拉框列表
    select_options_loc = (By.XPATH, "//ion-list[@class='sc-ion-select-popover md list-md hydrated']")

    # 题型选择
    question_types_loc = (By.XPATH, "//label[text()='题型选择']//following-sibling::ion-select")
    # 等级选择
    levels_loc = (By.XPATH, "//label[text()='等级选择']//following-sibling::ion-select")
    # 难度选择
    difficulty_loc = (By.XPATH, "//label[text()='难度选择']//following-sibling::ion-select")
    # 适用课程类型
    course_types_loc = (By.XPATH, "//label[text()='适用课程类型']//following-sibling::ion-select")

    # 题目名称输入框
    subject_name_loc = (By.XPATH, "//label[text()='题目名称']//following-sibling::ion-input/input")
    # 创建人输入框
    create_name_loc = (By.XPATH, "//label[text()='创建人']//following-sibling::ion-input/input")

    # 下拉框-等级、题型、难度、类型
    option_loc = (By.XPATH, "//ion-label[text()=' {} ']/..")

    # 题目文本
    subject_text1 = (By.XPATH, "//input[@placeholder='请输入文本一（最多可输入50字符）']")
    subject_text2 = (By.XPATH, "//input[@placeholder='请输入文本二（最多可输入200字符）']")
    subject_text3 = (By.XPATH, "//textarea[@placeholder='请输入文本三（最多可输入300字符）']")
    # 上传
    # 上传题目图片:
    # upload_subject_img_loc = (By.XPATH, "//tr[contains(., '题目图片:')]//input[@accept='.jpg,jpeg,.png']")
    upload_subject_img_loc = (By.XPATH, "//div[@class='upload-image__button']/input")
    upload_subject_cimg_loc = (By.XPATH, "//tr[contains(., '题目图片:')]//ion-button[text()=' 上传图片 ']//following-sibling::input")
    upload_answers_cimg_loc = (By.XPATH, "//tr[contains(., '参考答案:')]//ion-button[text()=' 上传图片 ']//following-sibling::input")
    # 知识点输入框
    knowledge_point_loc = (By.XPATH, "//input[@placeholder='最多可输入100字符']")
    # 评分标准输入框
    scale_rule_loc = (By.XPATH, "//textarea[@placeholder='最多可输入200字符']")
    # 题目预置代码
    preset_code_loc = (By.XPATH, "//textarea[@placeholder='最多可输入3000字符']")
    # 参考答案
    reference_version_loc = (By.XPATH, "//label[text()='参考答案:']/..//following-sibling::td//textarea")

    # 保存
    save_loc = (By.XPATH, "//div[text()=' 保存并继续 ']")

    # toast提示
    save_toast_loc = (By.XPATH, "//div[@class='toast-message']")

    # --------------------------------------------列表搜索条件---------------------------------------------
    # 题目名称输入框
    subject_search_name_loc = (By.XPATH, "//label[text()='题目名称:']//following-sibling::ion-input/input")
    # 题目ID输入框
    subject_search_id_loc = (By.XPATH, "//label[text()='题目ID:']//following-sibling::ion-input/input")
    # 创建人输入框
    subject_created_loc = (By.XPATH, "//label[text()='创建人:']//following-sibling::ion-input/input")
    # 题型下拉框
    search_question_types_loc = (By.XPATH, "//label[text()='题型:']//following-sibling::ion-select")
    # 适用课程类型下拉框
    search_course_types_loc = (By.XPATH, "//label[text()='适用课程类型:']//following-sibling::ion-select")
    # 等级下拉框
    search_levels_loc = (By.XPATH, "//label[text()='等级:']//following-sibling::ion-select")
    # 难度级别下拉框
    search_difficulty_loc = (By.XPATH, "//label[text()='难度级别:']//following-sibling::ion-select")
    # 搜索按钮
    search_button_loc = (By.XPATH, "//div[text()=' 搜索 ']")
    # 重置按钮
    reset_button_loc = (By.XPATH, "//div[text()=' 重置 ']")
    # 列表数据
    lst_body_loc = (By.XPATH, "//datatable-body[@class='datatable-body']")
    lst_body_row_loc = (By.XPATH, "//datatable-row-wrapper[@class='datatable-row-wrapper']")
    # 删除列表数据
    del_row_loc = (By.XPATH, "//span[text()='删除']")
    # 确认删除弹窗-确定
    alert_del_loc = (By.XPATH, "//span[text()='确定']/..")


class ExaminationPaperLocator:
    # -------------------试卷管理列表页--------------------------------
    add_ep_loc = (By.XPATH, "//div[text()=' 新增试卷 ']")  # 新增试卷名称
    ep_lst_name_input_loc = (By.XPATH, "//label[text()='试卷名称:']/..//input")  # 列表页试卷名称输入框
    ep_lst_id_input_loc = (By.XPATH, "//label[text()='试卷ID:']/..//input")  # 列表页试卷ID输入框
    ep_lst_created_input_loc = (By.XPATH, "//label[text()='创建人:']/..//input")  # 列表页创建人输入框
    ep_lst_search_loc = (By.XPATH, "//div[text()=' 搜索 ']")  # 列表页搜索按钮
    ep_lst_reset_loc = (By.XPATH, "//div[text()=' 重置 ']")  # 列表页重置按钮

    # -------------------新增试卷页面-----------------------------------
    ep_name_loc = (By.XPATH, "//input[@placeholder='试卷名称']")  # 试卷名称
    ep_created_loc = (By.XPATH, "//input[@placeholder='创建人']")  # 创建人
    ep_select_types_loc = (By.XPATH, "//ion-select[@placeholder='适用课程类型']")  # 适用课程类型
    ep_select_levels_loc = (By.XPATH, "//ion-select[@placeholder='等级']")  # 适用等级
    ep_select_difficulty_loc = (By.XPATH, "//ion-select[@placeholder='难度级别']")  # 难度级别
    ep_option_loc = (By.XPATH, "//ion-label[text()=' {} ']/..")  # 适用课程类型具体选项
    ep_result_chinese_copy_loc = (By.XPATH, "//label[text()='结果页中文文案']/..//following-sibling::td//input")
    ep_result_english_copy_loc = (By.XPATH, "//label[text()='结果页英文文案']/..//following-sibling::td//input")
    ep_add_subject_loc = (By.XPATH, "//span[text()='添加题目']")  # 添加题目
    ep_save_loc = (By.XPATH, "//ion-button[text()='保存']")  # 新增试卷页-保存
    ep_toast_loc = (By.XPATH, "//div[@class='toast-container']")
    ep_toast1_loc = (By.XPATH, "//div[@class='toast-content']")
    ep_toast2_loc = (By.XPATH, "//div[@class='toast-message']")

    # --------------------选择题目弹窗-------------------------------------
    ep_choice_window_subject_name_loc = (By.XPATH, "//input[@placeholder='题目名称']")  # 添加题目-弹窗-题目名称输入框
    ep_choice_window_search_loc = (By.XPATH, "//ion-button[text()='搜索']")  # 添加题目-弹窗-搜索
    ep_choice_window_checkbox_loc = (By.XPATH, "//input[@type='checkbox']")  # 添加题目-弹窗-全选
    ep_choice_window_save_loc = (By.XPATH, "//button[text()=' 保存 ']")  # 添加题目-弹窗-全选

# <div class="toast-container" part="container">
#     <div class="toast-content">
#         <div class="toast-message" part="message">请填写试卷名称</div>
#     </div>
# </div>
